from collections import deque


class RecentCounter:

    def __init__(self):
        # self.q = []
        self.q = deque() # deque性能好像好点



    def ping(self, t: int) -> int:
        self.q.append(t)
        while self.q[0] < t - 3000:
            # self.q.pop(0)
            self.q.popleft()
        return len(self.q)



# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)